﻿using FluentValidation.AspNetCore;
using Microsoft.Extensions.DependencyInjection;
using Solution.Application.Commands.Dependency;
using System;

namespace Solution.Application.Injection
{
    public static class FluentValidationInjection
    {
        public static void AddFluentValidation(this IServiceCollection services)
        {
            services.AddFluentValidation(configurationExpression =>
            {
                configurationExpression.RegisterValidatorsFromAssemblyContaining<BaseAbstractValidator<object>>();
                //Compatibility with ASP.NET’s built-in Validation
                configurationExpression.DisableDataAnnotationsValidation = false;
            });
        }
    }
}